home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / libio-compress-zlib-perl / examples / gzcat < prev    next >
Encoding:
Text File  |  2008-02-18  |  504 b   |  30 lines

  1. #!/usr/local/bin/perl
  2.  
  3. use IO::Uncompress::Gunzip qw( $GunzipError );
  4. use strict ;
  5. use warnings ;
  6.  
  7. #die "Usage: gzcat file...\n"
  8. #    unless @ARGV ;
  9.  
  10. my $file ;
  11. my $buffer ;
  12. my $s;
  13.  
  14. @ARGV = '-' unless @ARGV ;
  15.  
  16. foreach $file (@ARGV) {
  17.     
  18.     my $gz = new IO::Uncompress::Gunzip $file
  19.          or die "Cannot open $file: $GunzipError\n" ;
  20.  
  21.     print $buffer
  22.         while ($s = $gz->read($buffer)) > 0 ;
  23.  
  24.     die "Error reading from $file: $GunzipError\n" 
  25.         if $s < 0 ;
  26.     
  27.     $gz->close() ;
  28. }
  29.  
  30.